/*
   - SoftwareSerial Library:  http://www.arduino.cc/en/Reference/SoftwareSerial
*/
#include "string.h"
#include "ctype.h"
#include "SoftwareSerial.h"
#include "pins_arduino.h"
#include "math.h"
#include "Arduino.h"
#include "dwifiTCP.h"

dwifiTCP tcpserver=dwifiTCP();
/* Setup serial connections. */
void setup()
{ 
  Serial.end();                  // Close any previously established connections
  Serial.begin(9600);            // Arduino Baud Rates
  tcpserver.init();
  delay(100);
  tcpserver.ssid="CFSOFTWARE_WAN";
  tcpserver.key="4A455355535F53415645535553";
}

void loop()
{
  Serial.println("Test");
  String data="hello how are you?";
  delay(1000);
  // tcpserver.setWpa();
  tcpserver.setWep();
  tcpserver.associate_with_network(true);
  int TCP_serverCID = tcpserver.server_start(100);
//  tcpserver.cid_check();
  //tcpwifi.tcp_write(data, TCP_CID);
  delay(8000);
  Serial.println("Delay over");
  while(tcpserver.readall()==0){
    Serial.println("okay");}
  Serial.println("done");
  while(true){Serial.println("ready to read..."); tcpserver.tcp_read(TCP_serverCID);}
}
